import Config from "./Config";
import Model from "./Model";
import WxUtil from "./WxUtil";
import Core from "./Core";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Loading extends cc.Component {

   @property(cc.Label)
   label: cc.Label = null;

   @property(cc.Node)
   progress: cc.Node = null;

   onLoad() {
      var urls = ['resources/textures/menu/menu.png'];
      cc.loader.loadResDir('textures', this.onProgress.bind(this), this.onComplete.bind(this));
   }
   onProgress(loaded, total) {
      this.label.getComponent(cc.Label).string = Math.ceil(loaded / total * 100) + '%';
      this.progress.getComponent(cc.ProgressBar).progress = loaded / total;
   }
   onComplete(e) {

      Config.init()
      Core.init()
      Model.loadData()
      WxUtil.showShareMenu()
      // WxUtil.initBanner()
      WxUtil.initVideo()
      WxUtil.initInterstitialAd()
      WxUtil.initGridAd()

      cc.director.loadScene('menu')

   }
}
